package com.zhucan.stream.consumer;

import com.zhucan.stream.binder.OrderStreamBinder;
import com.zhucan.stream.binder.event.OrderEvent;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.stream.annotation.StreamListener;
import org.springframework.messaging.handler.annotation.Payload;
import org.springframework.stereotype.Service;

/**
 * @author zhuCan
 * @email zhucan@co-mall.com
 * @description
 * @since 2020/8/20 9:10
 */
@Slf4j
@Service
public class OrderConsumer {

  @StreamListener(
      value = OrderStreamBinder.ORDER_INPUT
  )
  public void consume(@Payload Object data){
    log.info("接收到数据:consume {}", data);
  }

  @StreamListener(
      value = OrderStreamBinder.ORDER_INPUT,
      condition = "headers['destination']=='route'"
  )
  public void consumeHeader(@Payload OrderEvent data){
    log.info("接收到数据:consumeHeader {}", data);
  }

  @StreamListener(
      value = OrderStreamBinder.ORDER_INPUT_ROUTE
  )
  public void consumeRoute(@Payload OrderEvent data){
    log.info("接收到数据:consumeRoute {}", data);
  }

  @StreamListener(
      value = OrderStreamBinder.ORDER_INPUT_ROUTE_TEST
  )
  public void consumeRouteTest(@Payload OrderEvent data){
    log.info("接收到数据:consumeRouteTest {}", data);
  }
}
